import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";


// 创建一个事件总线
const eventBus = {
  events: {},
  $on(event: string, callback: () => void) {
    if (!(this.events as any)[event]) {
      (this.events as any)[event] = [];
    }
    (this.events as any)[event].push(callback);
  },
  $emit(event: string, ...args: any[]) {
    if ((this.events as any)[event]) {
      (this.events as any)[event].forEach((callback: any) => {
        callback(...args);
      });
    }
  },
};

// 将事件总线注入到应用实例中
createApp(App).provide("eventBus", eventBus).use(store).use(router).mount("#app");